import Count from "@/pages/shop/components/count/count.vue";
export default {
  name: "Count",
  components: {
    Count,
  },
  data() {
    return {
      tableData: [
        {
          detail: "湖北莲子500克，颗颗饱满，鲜甜可口，清热解毒，夏季食品",
          price: "55.00",
          count: "2",
          total: "110.00",
        },
        {
          detail: "湖北莲子500克，颗颗饱满，鲜甜可口，清热解毒，夏季食品",
          price: "55.00",
          count: "2",
          total: "110.00",
        },
        {
          detail: "湖北莲子500克，颗颗饱满，鲜甜可口，清热解毒，夏季食品",
          price: "55.00",
          count: "2",
          total: "110.00",
        },
      ],
      multipleSelection: [],
      selectCount: 0,
      selectAll: false,
    };
  },

  methods: {
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
      this.selectCount = this.multipleSelection.length;
    },
    deleteRow(index, rows) {
      rows.splice(index, 1);
    },
    toggleAllSelection(checked) {
      if (checked) {
        this.tableData.forEach((t) => {
          this.$refs.multipleTable.toggleRowSelection(t);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }

      this.selectAll = checked;
    },
    deleteAll() {
      this.tableData = [];
    },
    goCount() {
      this.$router.push({ path: "/shop/count" });
    },
    changeSelectAll() {
      this.selectAll = this.multipleSelection.length === this.tableData.length;
    },
  },
};
